package io.renren.modules.ht.controller;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.ht.entity.ContractsAmountEntity;
import io.renren.modules.ht.service.ContractsAmountService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;
import java.util.Map;


/**
 * 
 *
 * @author chenhonghua
 * @email 277765406@qq.com
 * @date 2023-11-20 13:40:14
 */
@RestController
@RequestMapping("ht/contractsAmount")
public class ContractsAmountController {
    @Autowired
    private ContractsAmountService contractsAmountService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("ht:contractsAmount:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = contractsAmountService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("ht:contractsAmount:info")
    public R info(@PathVariable("id") Integer id){
        ContractsAmountEntity contractsAmount = contractsAmountService.getById(id);
        return R.ok().put("contractsAmount", contractsAmount);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("ht:contractsAmount:save")
    public R save(@RequestBody ContractsAmountEntity contractsAmount){
		contractsAmountService.save(contractsAmount);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("ht:contractsAmount:update")
    public R update(@RequestBody ContractsAmountEntity contractsAmount){
		contractsAmountService.updateById(contractsAmount);
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("ht:contractsAmount:delete")
    public R delete(@RequestBody Integer[] ids){
		contractsAmountService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }
    @RequestMapping("/getContractsAmountList")
    public R getContractsAmountList(){
        List<ContractsAmountEntity> list = contractsAmountService.list();
        return R.ok().put("data", list);
    }
}
